package br.com.abril.prevision;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class ExecutivePrevisionService {

	@Autowired
	private ExecutivePrevisionRepository repository;
	
	public ExecutivePrevisionRepository allPrevisions() {
		return repository;
	}
	
	public List<ExecutivePrevision> findExecutivesforPrevisionByWallet (String wallet) {
		return this.repository.findByWalletAndDataReservaIsNotNullOrderByDataReservaDesc(wallet);
	}
	
	//todo criar base service
	@Transactional
	public void save (List<ExecutivePrevision> previsions) {
		repository.save(previsions);
	}	
	
}
